package github.redspider;

import java.util.concurrent.*;

/**
 * @Author: DRevelation
 * @Date: 2021/2/23 17:09
 */
public class ExecutorServiceDemo {
    public static void main(String[] args) {
//        ExecutorService exec = Executors.newSingleThreadExecutor();
//        Future<Object> future = exec.submit(() -> "哈哈哈");
//        try {
//            System.out.println("future.get() = " + future.get());
//        } catch (Exception e) {
//            e.printStackTrace();
//        } finally {
//            exec.shutdown();
//        }

        ExecutorService exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);

        Thread t = new Thread(() -> System.out.println("thread"), "thread线程");
        t.start();

        exec.submit(() -> System.out.println("executor"), "thread线程池");
        exec.shutdown();
    }

}
